import java.util.Arrays;
import java.util.Random;

public class Main {

    public static void orderArr(int[] arr){
        for(int i=0;i<arr.length;i++){
            arr[i]=i;
            //arr[i]=arr.length-1;
        }
    }

    public static  void notOrderArr(int[] arr){
        Random random =new Random();
        for(int i=0;i<arr.length;i++){
            arr[i]=random.nextInt(10_0000);
        }
    }

    public static void testInsert(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.insetSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("直接插入排序耗时："+(endTime-startTime));
    }

    public static void testShell(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.shellSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序耗时："+(endTime-startTime));
    }

    public static void testSelect(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.selectSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("选择排序耗时："+(endTime-startTime));
    }

    public static void testSelect2(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.selectSort2(array);
        long endTime = System.currentTimeMillis();
        System.out.println("双指针选择排序耗时："+(endTime-startTime));
    }

    public static void testHeap(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.heapSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("堆排序耗时："+(endTime-startTime));
    }


    public static void testBubble(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.bubbleSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("冒泡排序耗时："+(endTime-startTime));
    }

    public static void testQuick(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.quickSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序耗时："+(endTime-startTime));
    }

    public static void testMergeSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.mergeSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("归并排序耗时："+(endTime-startTime));
    }


    public static void testOther() {
        int[] array = new int[10_0000];

        notOrderArr(array);
        //orderArr(array);
        testInsert(array);
        testShell(array);
        testSelect(array);
        testSelect2(array);
        testHeap(array);
        testBubble(array);
        testQuick(array);
        testMergeSort(array);
    }

    public static void testSimple() {
        int[] arr ={2,3,1,4,6,5,9,7,8};
        System.out.println("排序前："+ Arrays.toString(arr));
        //Sort.insetSort(arr);
        Sort.countSort(arr);
        System.out.println("排序后："+ Arrays.toString(arr));
    }

    public static void main(String[] args) {
        //testOther();
        testSimple();
    }
}